package com.stone.sys.action;

/**
 * <pre>
 * 日志查询Action
 * @author jz
 * </pre>
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.stone.para.IConstant;
import com.stone.sys.pojo.TLog;
import com.stone.sys.service.LogService;
import com.stone.utils.StringUtils;

import frm.ssh.action.BaseListAction;

public class LogListAction extends BaseListAction {

	private static final long serialVersionUID = 3979577965804736350L;

	private LogService logService;
	
	public LogService getLogService() {
		return logService;
	}

	public void setLogService(LogService logService) {
		this.service = logService;
		this.logService = logService;
	}
	
    /** * 构造方法. */
    public LogListAction() {
        this.entityClass = TLog.class;
    }

	/**
	 * 设置查询条件
	 */
	public HashMap<String, Object> setSearchCondition() {
		
		HashMap<String, Object> m = new HashMap<String, Object>();
		
		List<Object> valsList = new ArrayList<Object>();
		
		m.put("cols", "log");
		
		String conditions = "1=1"; 
		
		if (!"1".equals(this.getSessionAttribute(IConstant.SESSION_ISADMIN))) {
			conditions += " AND log.ouid = '" + super.getSession().getAttribute(IConstant.SESSION_TORGAN_CODE) + "'";
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon1())) {
			conditions += " AND TO_CHAR(log.logtime,'yyyy-MM-dd') >= ?";
			valsList.add(super.getSearchBean().getCon1());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon2())) {
			conditions += " AND TO_CHAR(log.logtime,'yyyy-MM-dd') <= ?";
			valsList.add(super.getSearchBean().getCon2());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon3())) {
			conditions += " AND userid like ?";
			valsList.add("%" + super.getSearchBean().getCon3() + "%");
		}
		
		// 查询条件
		m.put("conditions",conditions);
		m.put("clause", " order by log.logtime Desc");
		m.put("alias", "log");
		m.put("vals", valsList.toArray());
		
		return m;
		
	}

}
